#ifndef   _DATA_BUFFER_H
#define   _DATA_BUFFER_H

#include <stdio.h>
#define  BUFFER_UNIT_SIZE   128

typedef struct buffer_chain_element
{
	struct	buffer_chain_element *next;
	char	data_buffer[BUFFER_UNIT_SIZE];
	int		end_pos;
	int		start_pos;
}_buf_element_t;

typedef struct buffer_chain
{
	buffer_chain_element *p_head,*p_tail;
	int buffer_size;
}_chain_t;

class BufferChain
{
protected:
	struct buffer_chain *m_pBuffer;
public:
	BufferChain(void);
	~BufferChain(void);
	void InitBufferChain(void);
	void AddToTail(char *p_data,int data_len);
	void FreeMemFromHead(int data_len);
	void GetDataFromHead(void *p_retBuff,int data_len);
	void GetDataBuffer(char **buffer, int *len);
};

#endif